#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int a = 0, b = 0;
	int i = 0, Min = 0;
	scanf("%d %d", &a, &b);
	Min = a < b ? a : b;
	for (i = Min; i >= 1; i-- )
	{
		if (0 == a % i && 0 == b % i)
			break;
	}
	printf("%d\n", i);
	return 0;
}
